<?php
    class Xu_ly
    {
        function xu_ly_chuoi($str)
        {
        	$tach_chuoi=explode('-', $str);
        	$key=$tach_chuoi[count($tach_chuoi)-1];
        	$tach_chuoi=explode('.',$key);
        	$key=$tach_chuoi[0];
        	return $key;
        }
        
      function dmy_to_ymd($ngay)
	{
		$kq = '';
		$mang = explode('/', $ngay);
		$kq = "{$mang[2]}-{$mang[1]}-{$mang[0]}";
		
		return $kq;
	}
	function ymd_to_dmy($ngay)
	{
		$kq = '';
		if(strlen($ngay)>10)
		{
			$mang = explode(' ', $ngay);
			$ngay = $mang[0];
		}
		
		$mang = explode('-', $ngay);
		$kq = "{$mang[2]}/{$mang[1]}/{$mang[0]}";
		
		return $kq;
	}
    
	
	function tao_datetimepicker($name, $selected_date='', $format='dd/mm/yy')
	{
		$html = '<div>
				<input type="text" name="'.$name.'" id="'.$name.'" value="'.$selected_date.'" style="width:150px"/>
				<img id="img_'.$name.'" src="'.base_url('public/tien_ich/datetimepicker/img/date-picker/cal.png').'" alt="hinh"/></div>
				<script type="text/javascript">
				  //define function to be executed on document ready
				  $(function(){
					var pickerOpts = {
						dateFormat:"'.$format.'"
					};
					//create the date picker
					$("#'.$name.'").datepicker(pickerOpts);
					
					$("#img_'.$name.'").click(function() {
						
						$("#'.$name.'").focus();
					});
				  });
				</script>
		';
		
		return $html;
	}  
    }
    
    
    
?>